package com.bjfu.controller;

import com.bjfu.dto.*;
import com.bjfu.model.Team;
import com.bjfu.model.User;
import com.bjfu.service.SuperManagerService;
import com.bjfu.service.TeamAdminService;
import com.bjfu.utils.Result;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/TeamAdmin")
public class TeamAdminController {
    @Autowired
    private TeamAdminService teamAdminService;
    @Autowired
    private SuperManagerService superManagerService;

    //获取所有成果
    @GetMapping("/getAchievements")
    public Result getAchievements() {
        return teamAdminService.getAchievements();
    }
    //获取所有文章
    @GetMapping("/getArticles")
    public Result getArticles() {
        return teamAdminService.getArticles();
    }
    //获取某类成果
    @GetMapping("/getAchievement")
    public Result getAchievement(@RequestParam Integer category) {
        return teamAdminService.getAchievement(category);
    }
    //获取所有不公开成果
    @GetMapping("/getNotOpenAchievements")
    public Result getNotOpenAchievements() {
        return teamAdminService.getNotOpenAchievements();
    }
    //获取某类不公开成果
    @GetMapping("/getNotOpenAchievement")
    public Result getNotOpenAchievement(@RequestParam Integer category) {
        return teamAdminService.getNotOpenAchievement(category);
    }

    //获取所有可以被注销用户信息
    @GetMapping("/getNeedCancelUsers")
    public Result getNeedCancelUsers() {
        return teamAdminService.getNeedCancelUsers();
    }
    //获取所有待审核用户信息
    @GetMapping("/getWaitJudgeUsers")
    public Result getWaitJudgeUsers() {
        return teamAdminService.getWaitJudgeUsers();
    }
    //根据用户名获取用户信息
    @GetMapping("/getUserInfoByUserName")
    public Result  getUserInfoByUserName(@RequestParam String username) {
        return teamAdminService.getUserInfoByUserName(username);
    }

    //根据邮箱获取用户信息
    @GetMapping("/getUserInfoByEmail")
    public Result  getUserInfoByEmail(@RequestParam String email) {
        return teamAdminService.getUserInfoByEmail(email);
    }

    //根据邮箱获取用户信息
    @GetMapping("/getAllQuestions")
    public Result  getAllQuestions() {
        return teamAdminService.getAllQuestions();
    }

    //根据问题id获取问题信息
    @GetMapping("/getQuestionInfo")
    public Result  getQuestionInfo(@RequestParam Long question_id) {
        return teamAdminService.getQuestionInfo(question_id);
    }

    //根据问题状态获取问题
    @GetMapping("/getAllQuestionsByStatus")
    public Result  getAllQuestionsByStatus(@RequestParam Integer status) {
        return teamAdminService.getAllQuestionsByStatus(status);
    }
    //根据user_id获取权限
    @GetMapping("/getPermitByUserId")
    public Result  getPermitByUserId(@RequestParam Long user_id) {
        return teamAdminService.getPermitByUserId(user_id);
    }

    // 更改团队信息
    @PutMapping("/updateTeamInfo")
    public Result updateTeamInfo(@RequestBody TeamDTO team) {
        return teamAdminService.updateTeamInfo(team);
    }
    // 添加成员
    @PostMapping("/addMember")
    public Result addMember(@RequestBody MemberRequestDTO user) {
        return teamAdminService.addMember(user);
    }

    // 修改成员信息
    @PutMapping("/updateMemberInfo")
    public Result updateMemberInfo(@RequestBody UpdateAdminInfoRequest userInfo) {
        return superManagerService.updateAdminInfo(userInfo);
    }

    // 查询所有待审核的团队成员信息
    @GetMapping("/queryPendingMembers")
    public Result queryPendingMembers() {
        return teamAdminService.queryPendingMembers();
    }

    // 审核团队成员信息
    @PostMapping("/judgeTeamMemberInfo")
    public Result judgeTeamMemberInfo(@RequestBody JudgeRequest judgeRequest) {
        System.out.println(judgeRequest);
        // 处理业务逻辑
        return teamAdminService.judgeTeamMemberInfo(judgeRequest);
    }
    //增加成果
    @PostMapping("/addAchievement")
    public Result addAchievement(@RequestBody AchievementDTO achievementDTO){
        System.out.println(achievementDTO);
        return teamAdminService.addAchievement(achievementDTO);
    }
    //增加文章addArticle
    @PostMapping("/addArticle")
    public Result addArticle(@RequestBody ArticleDTO articleDTO){
        System.out.println(articleDTO);
        return teamAdminService.addArticle(articleDTO);
    }
    //编辑成果
    @PutMapping("/updateAchievement")
    public Result updateAchievement(@RequestBody AchievementDTO achievementDTO){
        System.out.println(achievementDTO);
        return teamAdminService.updateAchievement(achievementDTO);
    }
    //编辑文章
    @PutMapping("/updateArticle")
    public Result updateArticle(@RequestBody ArticleDTO articleDTO){
        System.out.println(articleDTO);
        return teamAdminService.updateArticle(articleDTO);
    }
    //删除成果
    @DeleteMapping("/deleteAchievement")
    public Result deleteAchievement(@RequestParam Long achievement_id){
        System.out.println(achievement_id);
        return teamAdminService.deleteAchievement(achievement_id);
    }
    @DeleteMapping("/deleteArticle")
    public Result deleteArticle(@RequestParam Long article_id) {
        System.out.println(article_id);
        return teamAdminService.deleteArticle(article_id);
    }
    //可设置科研成果的展示状态
    @PostMapping("/changeAchievementStatus")
    public Result changeAchievementStatus(@RequestBody AchievementDTO achievementDTO){
        System.out.println(achievementDTO);
        return teamAdminService.changeAchievementStatus(achievementDTO);
    }
    //审核注册
    @PostMapping("/shenhe")
    public Result shenHe(@RequestBody JudgeRequest judgeRequest){
        System.out.println(judgeRequest);
        // 处理业务逻辑
        return teamAdminService.shenheRegister(judgeRequest);
    }
    @PostMapping("/cancelUser")
    public Result cancelUser(@RequestParam Long user_id){
        System.out.println(user_id);
        return teamAdminService.cancelUser(user_id);
    }
    //重置指定用户的密码并将重置密码发送到其user_info中对应的邮箱地址
    @PostMapping("/ResetPasswordByUserId")
    public Result ResetPasswordByUserId(@RequestParam Long user_id){
        return teamAdminService.ResetPasswordByUserId(user_id);
    }
    //回复用户提问
    @PostMapping("/answerQuestion")
    public Result answerQuestion(@RequestBody QuestionDTO questionDTO){
        return teamAdminService.anwerQuestion(questionDTO);
    }
    //标记问题状态（关闭等）
    @PostMapping("/tagQuestion")
    public Result tagQuestion(@RequestBody QuestionDTO questionDTO){
        return teamAdminService.tagQuestion(questionDTO);
    }
    @GetMapping("/getMemberAndUserInfo")
    public Result getMemberAndUserInfo(){
        return teamAdminService.getMemberAndUserInfo();
    }
}
